<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<link rel="stylesheet" type="text/css" href="css.css">
<TITLE>Sanewall, The configuration language.</TITLE>
<meta name="author" content="Costa Tsaousis">
<meta name="robots" content="noindex">
<meta name="description" content="

Home for sanewall, an iptables stateful packet filtering firewall builder for Linux (kernel 2.4),
supporting NAT, SNAT, DNAT, REDIRECT, MASQUERADE, DMZ, dual-homed, multi-homed and router setups,
protecting and securing hosts and LANs in all kinds of topologies. Configuration is done using
simple client and server statements while it can detect (and produce) its configuration
automatically. Sanewall is extremely easy to understand, configure and audit.

">

<meta name="keywords" content="iptables, netfilter, filter, firewall, stateful, port, secure, security, NAT, DMZ, DNAT, DSL, SNAT, redirect, router, rule, rules, automated, bash, block, builder, cable, complex, configuration, dual-homed, easy, easy configuration, example, fast, features, flexible, forward, free, gpl, helpme mode, human, intuitive, language, linux, masquerade, modem, multi-homed, open source, packet, panic mode, protect, script, service, system administration, wizard">
<meta http-equiv="Expires" content="Wed, 19 Mar 2003 00:00:01 GMT">
</HEAD>

<BODY bgcolor="#FFFFFF">

<p>


Sanewall configuration files are normal <a href="http://www.gnu.org/software/bash/bash.html">BASH</a> scripts.
As such, you can use all <a href="http://www.gnu.org/software/bash/bash.html">BASH</a> features within sanewall configuration
files, including functions, loops, variables, I/O, etc, etc.
<p>
I have chosen <a href="http://www.gnu.org/software/bash/bash.html">BASH</a> as the configuration language for sanewall
since it is the common denominator for a language that all UNIX system administrators and developers
(or at least those that respect themselves) know and understand better.

<center><table border=0 cellpadding=15 cellspacing=20 width="70%">
<tr><td bgcolor="#F0F0F0">
The fact that
sanewall uses <a href="http://www.gnu.org/software/bash/bash.html">BASH</a> for its configuration,
allows third parties to develop add-ons, to enable sanewall use
SQL databases, directory structures, DBM or other files, WEB front ends or other means for the rules of the firewall.
<p>
Exactly the same reason allows the build of remote managers for centralized administration of a large number of Linux hosts and
routers.
</td></tr>
</table>
</center>

The only <a href="http://www.gnu.org/software/bash/bash.html">BASH</a> features a sanewall configuration script should never use, is <b>traps</b> and the <b>exit</b> command. Traps are used by sanewall for cleaning
up all temporary files, and possibly restoring the previously running firewall in case sanewall execution breaks, and the exit command will not just exit the configuration file, it will exit
sanewall. Sanewall has disabled these features by default, so that you will not be able to use them, unless you specifically enable them.
<p>
Also, since a sanewall configuration script runs inline with sanewall, all variables and function names defined within the
configuration file overwrite the ones defined by sanewall. For this reason you should avoid using variables that start with
<b>SANEWALL_</b>, <b>work_</b>, <b>server_</b>, and <b>client_</b> as many such variables are used by sanewall internally.
There are also a number of functions names you should avoid, but there is no generic pattern at the moment. I suggest you should
avoid defining functions with the names of sanewall commands (interface, router, client, server, etc) and functions starting with <b>rules_</b>.
<p>
Note however that it is allowed to overwrite a few variables and functions if you want to modify sanewall services (See the <a href="adding.html">Adding Services</a> section for more on this).
<p>
To learn <a href="http://www.gnu.org/software/bash/bash.html">BASH</a> scripting I suggest the following documents:
<ul>
	<li><a href="http://www.tldp.org/LDP/abs/html/index.html">Advanced Bash-Scripting Guide</a> (updated)</li>
	<li><a href="http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html">BASH Programming - Introduction HOW-TO</a> (older)</li>
</ul>

<p>
<hr noshade size=1>
<table border=0 width="100%">
<tr><td align=center valign=middle>
	<A href="http://sourceforge.net"><IMG src="http://sourceforge.net/sflogo.php?group_id=58425&amp;type=5" width="210" height="62" border="0" alt="SourceForge Logo"></A>
</td><td align=center valign=middle>
	<b>Sanewall</b>, a firewall for humans...<br>
	&copy; Copyright 2004
	Costa Tsaousis <a href="mailto: costa@tsaousis.gr">&lt;costa@tsaousis.gr&gt</a>
</body>
</html>
